﻿
using System.Collections.Generic;
using NHibernate.Criterion;
using LIMS.Entities;
using System.Data;
namespace LIMS.DataAccess
{
    public interface IDao<T>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        T GetById(int id);

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        List<T> GetAll();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="maxResults"></param>
        /// <returns></returns>
        List<T> GetAll(int maxResults);

        /// <summary>
        /// /
        /// </summary>
        /// <param name="criterionList"></param>
        /// <returns></returns>
        List<T> GetByCriteria(params ICriterion[] criterionList);
        List<T> GetByCriteria(int maxResults, params ICriterion[] criterionList);
        T GetUniqueByCriteria(params ICriterion[] criterionList);
        List<T> GetSortedByCriteria(Order sortOrder, params ICriterion[] criterion);

        List<T> GetByExample(T exampleInstance, params string[] propertiesToExclude);
        T GetUniqueByExample(T exampleInstance, params string[] propertiesToExclude);
        T Save(T entity);
        T SaveOrUpdate(T entity);
        bool Delete(T entity);
        void CommitChanges();
        List<T> GetAllSorted(string sSortColumn, string sDirection);
        List<T> GetByQuery(string query);
        List<T> GetByQuery(int maxResults, string query);
        T GetUniqueByQuery(string query);

        bool QuickSaveOrUpdate(ref T entity);
        bool QuickDelete(T entity);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="grdData"></param>
        /// <returns></returns>
        List<T> GetAllForGridView(ref GridViewData grdData);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sQuery"></param>
        /// <param name="oList"></param>
        /// <param name="grdData"></param>
        /// <returns></returns>
        bool GetByMyQuery(string sQuery, ref List<T> oList, ref GridViewData grdData);
        /// <summary>
        /// Excute full text query
        /// </summary>
        /// <param name="sQuery"></param>
        /// <returns></returns>
        int ExecuteQuery(string sQuery);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="maxResults"></param>
        /// <param name="sQuery"></param>
        /// <returns></returns>
        List<T> GetBySimpleQuery(int maxResults, string sQuery);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Query"></param>
        /// <returns></returns>
        DataSet GetDataSetByQuery(string Query);
    }
}